const webpack = require('webpack')
export default {
  /*
  ** Nuxt rendering mode
  ** See https://nuxtjs.org/api/configuration-mode
  */
  mode: 'universal',
  srcDir: 'src/',
  env: {
    BASE_URL: process.env.BASE_URL,
    NODE_ENV: process.env.NODE_ENV
  },
  /*
  ** Nuxt target
  ** See https://nuxtjs.org/api/configuration-target
  */
  target: 'server',
  /*
  ** Headers of the page
  ** See https://nuxtjs.org/api/configuration-head
  */
  head: {
    title: '链配网 - 链接汽配产业优质资源',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no' },
      { hid: 'Keywords', name: 'Keywords', content: '汽配,汽车后市场' },
      { hid: 'description', name: 'description', content: '海量优质品牌厂商，各类数据查询端口，供应链体系应有尽有' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: 'http://member.ilianpei.com/bitbug_favicon.ico' },
      { rel: 'shortcut icon', type: 'image/x-icon', href: 'http://member.ilianpei.com/bitbug_favicon.ico' },
    ],
    script: [
      { src: 'https://hm.baidu.com/hm.js?882e6d568783d2743363bb0726733c99' },
      { src: 'https://alexcorvi.github.io/heic2any/dist/heic2any.js' }
    ]
  },
  /*
  ** Global CSS
  */
  css: [
    '@/assets/css/reset.css',
    'element-ui/lib/theme-chalk/index.css',
    '@/assets/css/common.css',
    '@/assets/iconfont/iconfont.css',
    'vant/lib/index.less',
    '~assets/css/editor.css', // 编辑器css
    'quill/dist/quill.snow.css',
    'quill/dist/quill.bubble.css',
    'quill/dist/quill.core.css',
  ],
  /*
  ** Plugins to load before mounting the App
  ** https://nuxtjs.org/guide/plugins
  * mode: 'client'   表示是仅在前端客户端生效
  * mode: 'server'   表示是仅在前端服务端生效
  */
  plugins: [
    { src: '~/plugins/util.js' },
    { src: '~/plugins/element-ui' },
    { src: '~/plugins/vant.js' },
    { src: '@/plugins/vue-quill-editor', ssr: false },
    { src: '~/plugins/nodata.js' },
    { src: '~/plugins/mint-ui.js' },
    { src: '@/plugins/heic2any', ssr: false },
    { src: '~/plugins/api' }
  ],
  // buildDir: 'nuxt-dist',
  /*
  ** Auto import components
  ** See https://nuxtjs.org/api/configuration-components
  */
  components: true,
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: [
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    '@nuxtjs/axios',
    '@gauseen/nuxt-proxy',
    'cookie-universal-nuxt'
  ],
  /*
  ** Build configuration
  ** See https://nuxtjs.org/api/configuration-build/
  */
  build: {
    vendor: ['element-ui', 'axios', 'qiniu'],
    postcss: {
      preset: {
        features: {
          customProperties: false
        }
      },
    },
    transpile: [/vant.*?less/],
    babel: {
      plugins: [
        ['import', {
          libraryName: 'vant',
          "style": (name) => {
            return `${name}/style/less.js`
          }
        }, 'vant']
      ],
    },
  },
  axios: {
    // baseURL: 'http://192.168.3.27:3000/'
    // baseURL: 'http://localhost:3000/'
    // baseURL: 'http://glc.ilianpei.com/'
    // baseURL: 'http://lianpeiwang.ip189.lhyw.net/'
  },
  // 跨域
  // proxyTable: {
  //   '/wap': {
  //     target: 'http://glc.ilianpei.com/', //API服务器的地址
  //     ws: true,  //代理websockets
  //     changeOrigin: true, // 虚拟的站点需要更管origin
  //     pathRewrite: {   //重写路径
  //       '^/wap': '/wap'
  //     }
  //   },
  //   '/common': {
  //     target: 'http://glc.ilianpei.com/', //API服务器的地址
  //     ws: true,  //代理websockets
  //     changeOrigin: true, // 虚拟的站点需要更管origin
  //     pathRewrite: {   //重写路径
  //       '^/common': '/common'
  //     }
  //   },
  //   '/home': {
  //     target: 'http://glc.ilianpei.com/', //API服务器的地址
  //     ws: true,  //代理websockets
  //     changeOrigin: true, // 虚拟的站点需要更管origin
  //     pathRewrite: {   //重写路径
  //       '^/home': '/home'
  //     }
  //   }
  // },
  // http://lianpeiwang.ip189.lhyw.net
  proxyTable: {
    '/wap': {
      target: 'http://lianpeiwang.ip189.lhyw.net/', //API服务器的地址
      ws: true,  //代理websockets
      changeOrigin: true, // 虚拟的站点需要更管origin
      pathRewrite: {   //重写路径
        '^/wap': '/wap'
      }
    },
    '/common': {
      target: 'http://lianpeiwang.ip189.lhyw.net/', //API服务器的地址
      ws: true,  //代理websockets
      changeOrigin: true, // 虚拟的站点需要更管origin
      pathRewrite: {   //重写路径
        '^/common': '/common'
      }
    },
    '/home': {
      target: 'http://lianpeiwang.ip189.lhyw.net/', //API服务器的地址
      ws: true,  //代理websockets
      changeOrigin: true, // 虚拟的站点需要更管origin
      pathRewrite: {   //重写路径
        '^/home': '/home'
      }
    }
  },
}
